package com.tmt.im.jpa.entity;

import com.tmt.data.jpa.entity.TmtBaseEntity;
import com.tmt.data.jpa.entity.TmtBaseEntityId;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

import java.io.Serial;
import java.io.Serializable;

/**
 * 用户的角色。
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/7/30 11:19
 * @Version 1.0
 **/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "im_user_role")
@Tag(name = "im_user_role", description = "用户角色表")
public class IMUserRole extends TmtBaseEntityId implements Serializable {

    @Serial
    private static final long serialVersionUID = 7435123395300647469L;

    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY, optional = false)
    private IMUser user;

    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY, optional = false)
    private IMRole role;

}